<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:p="http://primefaces.org/ui"
	xmlns:f="http://java.sun.com/jsf/core">
<h:body>
	<ui:composition template="/WEB-INF/templates/template.xhtml">
		<ui:define name="content">
				<h:form id="form">
					<p:growl id="growl" sticky="false" autoUpdate="true" showDetail="true" />
					<p:panel header="#{msg.title_cat_tab_b}">
						<p:commandButton value="#{msg.new}" icon="ui-icon-plusthick"
							onclick="PF('dlgNew').show();" update=":formNew:panelgrid_new" />
						<p:commandButton value="#{msg.ver}" icon="ui-icon-search"
							oncomplete="PF('dlgView').show();"
							update=":formView:panelgrid_view" />
						<p:commandButton value="#{msg.edit}" icon="ui-icon-pencil"
							onclick="PF('dlgEdit').show();" update=":formEdit:panelgrid_edit" />
						<p:commandButton value="#{msg.delete}" icon="ui-icon-trash"
							onclick="PF('dlgDelete').show();" />
						<br />
						<p:dataTable value="#{tb_controller.itemsList}" var="item"
							rows="10" paginator="true" currentPageReportTemplate="{startRecord} de {endRecord}"
							paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
							rowsPerPageTemplate="5,10,15" paginatorPosition="bottom"
							resizableColumns="true" selection="#{tb_controller.currentItem}"
							rowKey="#{item.idField}" id="table">
							<p:column selectionMode="single"
								style="width:16px;text-align:center" />
							<p:column headerText="#{msg.id}" sortBy="#{item.idField}"
								filterBy="#{item.idField}">
								<h:outputText value="#{item.idField}" />
							</p:column>
							<p:column headerText="#{msg.dsc}" sortBy="#{item.description}"
								filterBy="#{item.description}">
								<h:outputText value="#{item.description}" />
							</p:column>
							<p:column headerText="#{msg.val}" sortBy="#{item.value}"
								filterBy="#{item.value}">
								<h:outputText value="#{item.value}" />
							</p:column>
						</p:dataTable>
					</p:panel>
				</h:form>
				<!-- Panel for view -->
				<p:dialog header="#{msg.detail}" widgetVar="dlgView" style="position:fixed;">
					<h:form id="formView">
						<p:outputPanel id="outputPanel_view">
							<h:panelGrid columns="2" id="panelgrid_view">
								<p:outputLabel value="#{msg.id}" for="current_item_view_id" />
								<h:outputText value="#{tb_controller.currentItem.idField}"
									id="current_item_view_id" />
								<p:outputLabel value="#{msg.dsc}" for="current_item_view_dsc" />
								<h:outputText value="#{tb_controller.currentItem.description}"
									id="current_item_view_dsc" />
								<p:outputLabel value="#{msg.val}" for="current_item_view_value" />
								<h:outputText value="#{tb_controller.currentItem.value}"
									id="current_item_view_value" />
							</h:panelGrid>
							<div style="float:right;">
								<p:commandButton value="#{msg.accept}"
									onclick="PF('dlgView').hide();" type="button"
									icon="ui-icon-check" />
							</div>
						</p:outputPanel>
					</h:form>
				</p:dialog>
				<!-- End panel for view -->
				<!-- Panel for edit -->
				<p:dialog header="#{msg.edit}" widgetVar="dlgEdit" modal="true" style="position:fixed;">
					<h:form id="formEdit">
						<p:outputPanel id="outputPanelEdit">
							<h:panelGrid columns="3" id="panelgrid_edit">
								<p:outputLabel value="#{msg.id}" for="current_item_edit_id" />
								<h:outputText value="#{tb_controller.currentItem.idField}"
									id="current_item_edit_id" />
								<h:outputText value="" />
								<p:outputLabel value="#{msg.dsc}" for="current_item_edit_dsc" />
								<p:inputText value="#{tb_controller.input_edit_dsc}"
									id="current_item_edit_dsc" />
								<p:watermark value="#{tb_controller.currentItem.description}"
									for="current_item_edit_dsc" />
								<p:outputLabel value="#{msg.val}" for="current_item_edit_value" />
								<p:inputText value="#{tb_controller.input_edit_val}"
									id="current_item_edit_value" />
								<p:watermark value="#{tb_controller.currentItem.value}"
									for="current_item_edit_value" />
							</h:panelGrid>
							<h:panelGrid columns="2">
								<p:commandButton value="#{msg.accept}"
									oncomplete="handlRequest(xhr, status, args, 'dlgEdit')"
									icon="ui-icon-check"
									actionListener="#{tb_controller.onEditTableB}"
									update=":form:table" />
								<p:commandButton value="#{msg.cancel}"
									onclick="PF('dlgEdit').hide();" icon="ui-icon-close"
									actionListener="#{tb_controller.onEditCancelTableB}"
									immediate="true" />
							</h:panelGrid>
						</p:outputPanel>
					</h:form>
				</p:dialog>
				<!-- End panel for edit -->
				<!-- Panel for new -->
				<p:dialog header="#{msg.new}" widgetVar="dlgNew" modal="true" style="position:fixed;">
					<h:form id="formNew">
						<p:outputPanel id="outputPanelNew">
							<p:focus context=":formNew:outputPanelNew" />
							<h:panelGrid columns="3" id="panelgrid_new">
								<p:outputLabel value="#{msg.dsc}" for="current_item_new_dsc"
									style="tex-align:left;" />
								<p:inputText value="#{tb_controller.input_new_dsc}"
									id="current_item_new_dsc" required="true" label="#{msg.dsc}"
									requiredMessage="#{msg.required_input_dsc}" />
								<p:message for="current_item_new_dsc" />
								<p:outputLabel value="#{msg.val}" for="current_item_new_value" />
								<p:inputText value="#{tb_controller.input_new_val}"
									required="true" requiredMessage="#{msg.required_input_val}"
									id="current_item_new_value" label="#{msg.val}" />
								<p:message for="current_item_new_value" />
							</h:panelGrid>
							<h:panelGrid columns="2">
								<p:commandButton value="#{msg.accept}"
									oncomplete="handlRequest(xhr, status, args, 'dlgNew')"
									icon="ui-icon-check"
									actionListener="#{tb_controller.onSaveTableB}"
									update=":form:table :formNew:panelgrid_new" />
								<p:commandButton value="#{msg.cancel}"
									onclick="PF('dlgNew').hide();" icon="ui-icon-close"
									immediate="true"
									actionListener="#{tb_controller.onSaveCancelTableB}" />
							</h:panelGrid>
						</p:outputPanel>
					</h:form>
				</p:dialog>
				<!-- End panel for new -->
				<!-- Panel for delete -->
				<p:confirmDialog widgetVar="dlgDelete"
					header="#{msg.action_confirm}" message="#{msg.delete_item_message}">
					<h:form id="formDelete">
						<p:commandButton value="#{msg.accept}" update=":form:table"
							styleClass="ui-confirmdialog-yes" icon="ui-icon-check"
							oncomplete="PF('dlgDelete').hide();"
							actionListener="#{tb_controller.onDeleteTableB}" />
						<p:commandButton value="#{msg.cancel}"
							onclick="PF('dlgDelete').hide();" immediate="true"
							actionListener="#{tb_controller.onDeleteCancelTableB}"
							styleClass="ui-confirmdialog-no" icon="ui-icon-close" />
					</h:form>
				</p:confirmDialog>
				<!-- End panel for delete -->
		</ui:define>
	</ui:composition>

</h:body>

</html>